package Test;

import com.config.MyBatisConfig;
import com.config.SpringConfig;
import com.domain.Announcement;
import com.service.AnnouncementService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={SpringConfig.class, MyBatisConfig.class})
public class AnnouncementServiceTest {
    @Autowired
    private AnnouncementService announcementService;


    @Test
    public void findByIdTest(){
        System.out.println(announcementService.findById("1"));
    }

    @Test
    public void searchAnnouncementTest(){
        System.out.println(announcementService.searchAnnouncement(1,10).getRows());
    }



    @Test
    public void delAnnouncementTest(){
        System.out.println(announcementService.delAnnouncement("1"));  //改了类型
    }

    @Test
    public void editAnnouncementTest(){
        Announcement announcement=new Announcement();
        announcement.setId("1");
        announcement.setTitle("a");
        announcement.setContent("aa");                                 //改了类型，出错看这
        System.out.println(announcementService.editAnnouncement(announcement));
    }

}
